package com.concurrent.concurrentdemo.lock;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;

public class LockSupportDemo {

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            System.out.println("child start");
            LockSupport.park();
            System.out.println("child end");
        });
        thread.start();

        System.out.println("parent start");
        // 父线程先sleep2秒后再唤醒子线程
        TimeUnit.SECONDS.sleep(2);
        LockSupport.unpark(thread);
    }
}
